package com.zsy.mapper;

import com.zsy.entity.PurchaseRequirements;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface IPurchaseRequirementsMapper {


    /**
     *
     * @param userId 用户Id
     * @param relatedTo 关联项目
     * @param initiatingDepartment 申请部门
     * @param itemName 物品名称
     * @return
     */
    List<PurchaseRequirements> list(@Param("userId") Integer userId,
                                    @Param("relatedTo") String relatedTo,
                                    @Param("initiatingDepartment") String initiatingDepartment,
                                    @Param("itemName") String itemName);


    @Delete("UPDATE purchase_requirements SET is_deleted = 0 where purchase_requirements_id=#{purchaseRequirementsId}")
    int deleteById(Integer purchaseRequirementsId);

    @Update("update purchase_requirements set number = #{number}," +
            "related_to = #{relatedTo}," +
            "creation_time = #{creationTime}," +
            "initiating_department = #{initiatingDepartment}," +
            "filler = #{filler}," +
            "filling_time = #{fillingTime}," +
            "item_name = #{itemName}," +
            "required_quantity = #{requiredQuantity}," +
            "expected_arrival_time=#{expectedArrivalTime} " +
            "where purchase_requirements_id=#{purchaseRequirementsId}")
    int update(PurchaseRequirements purchaseRequirements);
}
